package com.greensam.pixelengine.pojo.emuns;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Ma Chengrui
 * @since 2025/9/16 14:05
 */
@Getter
@AllArgsConstructor
public enum PictureSizeEnum {

    TINY(0, "极小文件", 0L, 100 * 1024L),                   // <100KB
    SMALL(1, "小文件", 100 * 1024L, 500 * 1024L),                  // 100KB - 500KB
    MEDIUM(2, "中等文件", 500 * 1024L, 1024 * 1024L),              // 500KB - 1MB
    LARGE(3, "大文件", 1024 * 1024L, 5 * 1024 * 1024L),            // 1MB - 5MB
    HUGE(4, "超大文件", 5 * 1024 * 1024L, 10 * 1024 * 1024L),      // 5MB - 10MB
    MASSIVE(5, "特大文件", 10 * 1024 * 1024L, 50 * 1024 * 1024L),  // 10MB - 50MB
    GIANT(6, "巨型文件", 50 * 1024 * 1024L, Long.MAX_VALUE)        // >50MB

    ;

    private final Integer value;
    private final String description;
    private final Long minKb;
    private final Long maxKb;

    public static PictureSizeEnum getEnumByValue(Integer value) {
        for (PictureSizeEnum pixelEnum : PictureSizeEnum.values()) {
            if (pixelEnum.value.equals(value)) {
                return pixelEnum;
            }
        }
        return null;
    }

    public static PictureSizeEnum match(long sizeKb) {
        for (PictureSizeEnum e : values()) {
            if (sizeKb >= e.minKb && sizeKb < e.maxKb) {
                return e;
            }
        }
        return null;
    }
}
